import '~/style/login.less'
import Cookies from 'js-cookie'
import '~/assets/less/common.less'
import { msg } from '~/plugins/msg.js'
import http from '~/plugins/http.js'
import md5 from 'js-md5'

class Login{
  constructor () {
    this.init()
    this.onLogin()
    console.log('mode', process.env.MODE)
    this.getPublicKey()
  }
  init () {
    console.log("登录")
  }
  async getPublicKey () {
    const data = await http.get('http://192.168.1.32:8085/rsa/noAuth/getPublicKey')
    if (data) {
      console.log('getPublicKey', data)
    }
  }
  /**
   * 登录
   */
  onLogin () {
    $("#submit").on("click", () => {
      const userName = $('#userName').val()
      const password = $('#password').val()
      if (!userName || !password) {
        alert('请输入账户和密码')
        return
      }
      Cookies.set('token', md5(`${userName}-${password}`))
      console.log('登录请求', userName, password)
      window.location.href = '/index.html'
    })
  }
}

new Login()



